Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typings for EuiKeyPad #1229

Merged
merged 4 commits into from
Oct 3, 2018
Merged

Add typings for EuiKeyPad #1229

merged 4 commits into from
Oct 3, 2018

Conversation

timroes
Copy link
Contributor

@timroes timroes commented Oct 3, 2018

Summary

Adding typings for EuiKeyPad and its item components.

Checklist

  • [ ] This was checked in mobile
  • [ ] This was checked in IE11
  • [ ] This was checked in dark mode
  • [ ] Any props added have proper autodocs
  • [ ] Documentation examples were added
  • [ ] A changelog entry exists and is marked appropriately
  • [ ] This was checked for breaking changes and labeled appropriately
  • [ ] Jest tests were updated or added to match the most common scenarios
  • [ ] This was checked against keyboard-only and screenreader scenarios

Copy link
Member

@markov00 markov00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm no TS expert here, so I'll let @chandlerprall handle the review.

But you do still need to add a changelog entry.

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As Caroline said, needs a changelog entry; while the components' interfaces are unchanged, we treat TS definitions as a feature add (it's a change to the library's published/declared interface).

}

export interface EuiKeyPadMenuItemProps extends EuiKeyPadMenuItemCommonProps {
href: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't need to define href here as it's covered by HTMLAttributes<HTMLAnchorElement> when defining EuiKeyPadMenuItem

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah both of them are actually covered. My thought was, to make it more explicit that way, that they are taken by the component. I can remove both if you want.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove them; I think there's more of a chance they'd be a distraction when looking at this file than an aid. They were for me at least: 🤔this extends a button and has an explicit onClick, what's different about it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW this will also imply that href is required and can't be null or undefined.
If we are going to say: ok you can add or not an href props to that component I think it's fine to have the HTMLAttributes<HTMLAnchorElement> type manage this. If you want to force the component to have a non null non undefined href I think this is one way to go.
Is href required?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

href prop is not marked isRequired. Neither is onClick on EuiKeyPadMenuItemButton

}

export interface EuiKeyPadMenuItemButtonProps extends EuiKeyPadMenuItemCommonProps {
onClick: (ev: MouseEventHandler<HTMLButtonElement>) => void;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't need to define onClick here as it's covered by HTMLAttributes<HTMLButtonElement> when defining EuiKeyPadMenuItemButton

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops. didn't meant to approve this yet... see previous comments

@markov00
Copy link
Member

markov00 commented Oct 3, 2018

@timroes @chandlerprall I rewrite here my comment in case you missed it:
Adding the href and onClick also imply that href and onClick are required and can't be null or undefined as from HTMLAttributes<HTMLAnchorElement> definitions.
Are these props required or optional?

@timroes
Copy link
Contributor Author

timroes commented Oct 3, 2018

They are optional, so I removed them.

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new typedefs LGTM!

@timroes timroes merged commit 8287342 into elastic:master Oct 3, 2018
@timroes timroes deleted the ts-typings branch October 3, 2018 17:10
@snide snide mentioned this pull request Oct 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants